package controllers;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import services.ActorService;
import services.AuctionService;

@Controller
@RequestMapping("/auction")
public class AuctionController extends AbstractController {
	
	// Supporting services ----------------------------------------------------
	
	@Autowired
	private AuctionService auctionService;
	
	@Autowired
	private ActorService actorService;

	// Constructors -----------------------------------------------------------
	
	public AuctionController() {
		super();
	}
		
	// Listing ---------------------------------------------------------------		

	@RequestMapping("/listActive")
	public ModelAndView listActive() {
		ModelAndView result;
				
		result = new ModelAndView("auction/list");
		
		result.addObject("auctions", auctionService.findAllActiveAuctions());
		result.addObject("principal",actorService.findByPrincipal());
		result.addObject("URI", "/auction/listActive.do");
		
		return result;
	}
	
}